Mouse Actions (Ojbectdraw)
☆There are seven mouse actions ☆
- you can add these to any program that "extends WindowController"
- public void onMousePress(Location point)
- public void onMouseRelease (Location point)
- public void onMouseClick (Location point)
- public void onMouseMove (Location point)
- public void onMouseDrag (Location point)
- public void onMouseEnter (Location point)
- public void onMouseExit (Location point)

public void begin()
Initialize the program.
public void onMouseClick(Location point)
Define actions to take when the mouse button is clicked.
public void onMousePress(Location point)
Define actions to take when the mouse button is pressed.
public void onMouseRelease(Location point)
Define actions to take when the mouse button is released.
public void onMouseEnter(Location point)
Define actions to take when the mouse enters the window.
public void onMouseExit(Location point)
Define actions to take when the mouse exits the window.
public void onMouseDrag(Location point)
Define actions to take when the mouse is moved with the mouse button down.
public void onMouseMove(Location point)
Define actions to take when the mouse is moved with the mouse button up.

public void begin ( )

Programs written by extending Controller can perform any required initialization by defining a begin method containing the code to perform the initialization steps. You can make objects like citcle, rectangle (Filled or Framed), line, and text . More information about making objects look Drawable. Objects

Example :

public void begin()
{
box = new FilledRect( 140, 140, 120, 120, canvas); the yellow rectangle
box. setColor(Color. yellow); sets the color of the rectangle to yellow
hello = new FramedRect( 140, 140, 120, 120, canvas); the rectangle itself
love = new FilledRect( 198, 260, 8, 175, canvas); the bar that connect the base and the sign
steve = new FramedOval( 147, 148, 105, 105, canvas); the circle in the rectangle
Line2 = new Line( 140, 434, 260, 434, canvas); the base
bob = new Line( 161, 166, 236, 239, canvas); the diagonal line in the circle
message = new Text( "CLICKING" , 176, 194, canvas); //text box
}


void onMouseDrag(Location point)

Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Steps
1. keep track of last mouse location.
2. compare that to current location.
3. subtract current x- Last x for change in x
same for y's
4. move each object change x & y.
5. update get Mouse location.